home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / 491 / navel / compoundView.self < prev    next >
Encoding:
Text File  |  1993-07-13  |  1.9 KB  |  81 lines

  1. "compoundView.self,v 1.5 1993/07/13 21:47:28 richards Exp"
  2. "compoundView - parent of all views that have subViews"
  3.  
  4. traits views _AddSlotsIfAbsent: (| ^ compoundView = () |)
  5. traits views compoundView _Define: (|
  6.  
  7.     parent** = traits views view.
  8.  
  9.     creating* = (|
  10.     ^ realise: vmgr = (
  11.         resend.realise: vmgr.
  12.         subViews do: [|:s| s realise].
  13.         self).
  14.     |).
  15.     
  16.     destroying* = (|
  17.     ^ basicUnrealise = (
  18.         subViews do: [|:s| s basicUnrealise].
  19.         resend.basicUnrealise.
  20.         self).
  21.     |).
  22.     
  23.     "don't need to destroy subviews, cos all we do is request 
  24.      destruction, and clean up on destroyNotify!"
  25.     
  26.     copying* = (|
  27.     ^ copyUnrealised: sv = (|c| 
  28.         c: resend.copyUnrealised: sv.
  29.         c subViews: subViews copy.  " should be un-necessary. - mcr "
  30.         c subViews: subViews copyMappedBy: [|:s| s copyUnrealised: c].
  31.         c).
  32.     |).
  33.  
  34.     winOps* = (|
  35.     ^ map = (resend.map.
  36.         ifRealised: [subViews do: [|:s| s map]]).
  37.     |).
  38.  
  39.     subViewManagement* = (|
  40.  
  41.     ^ addSubView: v = (addSubView: v IfCyclic: [error: 'cyclic add']).
  42.     
  43.     ^ addSubView: v IfCyclic: b = (
  44.         (isSuperViewStar: v) ifTrue: b.
  45.         v removeFromSuperView.
  46.         subViews add: v.
  47.         v setSuperView: self.
  48.         ifRealised: [v realise].
  49.         mapped ifTrue: [v map].
  50.         self).
  51.     
  52.     ^ removeSubView: v = (
  53.         subViews remove: v.
  54.         v setSuperView: nil.
  55.         v unrealise.
  56.         self).
  57.  
  58.     ^ removeSubViews = (|svl|
  59.         svl: subViews copy.
  60.         svl do: [|:sv| removeSubView: sv].
  61.         self).
  62.  
  63.     "checks if v is in superView closure"
  64.     _ isSuperViewStar: v = ((== v) || 
  65.         [(superView notNil) && [superView isSuperViewStar: v]]).
  66.  
  67.     ^ subViewDo: aBlock = (
  68.         subViews do: aBlock.
  69.     ).
  70.     |).
  71.  
  72. |)
  73.  
  74. prototypes views _AddSlotsIfAbsent: (| ^ compoundView = () |)
  75. prototypes views compoundView _Define: view copy _AddSlots: (|
  76.     parent* = traits compoundView.
  77.  
  78.     "_" subViews <- list copy.
  79.     _ iName <- 'compoundView'.
  80. |)
  81.